package com.sjyang.lettuce;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author saijun.yang
 * @date 2022/3/21 18:57
 * @description 使用lettuce连接redis
 */
@Component
public class LettuceClient {
    @Autowired
    private RedisTemplate redisTemplate;
    public void redisClient(){
        RedisConnection redisConnection = redisTemplate.getConnectionFactory().getConnection();
        redisTemplate.opsForValue().set("k2","junjun");
        System.out.println(redisTemplate.opsForValue().get("k2"));
    }
}
